package gui.applets;

import java.applet.Applet;
import java.awt.Button;
import java.awt.Event;
import java.awt.List;
import java.awt.TextArea;

public class AppletList extends Applet {
	String[] floveor = { "Vanilla", "Mint", "Rum" ,"Frame","Rum"};

	List list = new List(6, true);
	TextArea ta = new TextArea(floveor.length, 30);
	Button btn = new Button("Test");

	int count = 0;

	public void init() {
		ta.setEditable(false);
		for (int i = 0; i < 3; i++)
			list.addItem(floveor[count++]);
		add(ta);
		add(list);
		add(btn);
	}
	
	public boolean action(Event evt,Object obj){
		if(evt.target.equals(list)){
			ta.setText("");
			String[] items=list.getSelectedItems();
			for(int i=0;i<items.length;i++){
				ta.append(items[i]+"\n");
			}
			
		}else if(evt.target.equals(btn)){
			if(count<floveor.length){
				list.addItem(floveor[count++]+"\n");
			}
		}
		else
			return super.action(evt, obj);
		return true;
		
	}
	
	
}
